﻿<style>
    body {
        background-color: #fff;
        overflow-y: scroll;
    }

    .titleA {
        color: #D04A02;
        font-size: 16px;
        text-decoration: underline;
        list-style-type: square;
        list-style-position: outside;
    }

        .titleA:hover {
            color: #f00;
        }

    .titleB {
        color: #602304;
        font-size: 16px;
        text-decoration: underline;
        list-style-type: square;
        list-style-position: outside;
    }

        .titleB:hover {
            color: #f00;
        }

    .searchType {
        padding: 5px 20px;
        border: 0px solid #ddd;
        color: #252424;
        font-size: 14px;
        display: inline-block;
        margin-right: 5px;
        background-color: #c7c7c7;
        cursor: pointer;
    }

        .searchType:hover, .searchType.current {
            background-color: #ff6a00;
            color: #fff;
        }

    .rtTitle {
        font-size: 17px;
        padding: 3px;
        color: #bb3106;
    }

    .rtRow {
        padding: 3px;
    }

    .spanTitle {
        font-size: 13px;
        font-weight: 300;
        color: #848282;
        font-family: inherit;
    }

    .spanText {
        font-size: 13px;
        font-family: Arial, sans-serif;
    }

    .marginCol6 {
        margin: 3px;
    }

    .tagSpan {
        padding: 0;
        display: inline-block;
        font-size: 12px;
        margin-left: 3px;
        border-radius: 2px;
        width: auto !important;
    }

        .tagSpan i {
            width: auto !important;
            margin-right: 10px;
            font-style: normal;
        }

    .fiterLog {
        display: inlne-block;
        padding: 5px;
        background-color: #f00;
        color: #fff;
    }

    .filterContent {
        padding: 5px;
        font-size: 12px;
        display: flex;
        align-items: center;
    }

    .searchInput {
        border: none;
        padding: 5px;
        width: 30vw;
        min-width: 150px;
        height: 43px;
    }

        .searchInput:focus {
            border: none;
            outline: none;
        }

    .Search_top_bg div i {
        background: #fff;
        height: 43px;
        display: block;
        width: 50px;
        float: left;
        font-size: 24px;
        line-height: 43px;
        padding: 0 10px;
    }

    .filterItem {
        padding: 5px 10px;
        list-style-type: none;
        background-color: #D04A02;
        border-radius: 25px;
        color: #fff;
        display: -webkit-inline-box;
    }

        .filterItem .removeitem {
            color: #fff;
            padding: 3px;
        }

    .removeA {
        font-size: 13px;
        color: #888;
        cursor: pointer;
        text-decoration: underline;
    }

        .removeA:hover {
            color: #f00;
        }

    .dataItem {
        border-bottom: 1px solid #d1d6d1;
        padding: 15px 0;
        display: flex;
        margin: 0 30px;
    }

    /*.fixDiv {
            padding: 5px;
            width: 220px;
            background-color: #d2f9d2;
            position: fixed;
            top: 150px;
            right: 0px;
            z-index: 100;
        }

        .fixDiv .item {
            padding: 10px;
            border: 1px dashed #4CAF50;
            color: #2f9204;
            font-size: 14px;
            margin: 5px;
            border-radius: 3px;
        }

        .fixDiv .wayItem {
            font-size: 30px;
            cursor: pointer;
            color: #aaa;
        }

        .fixDiv .wayItem:hover {
            color: #333;
        }

        .fixDiv .showmorebtn {
            color: #4CAF50;
            cursor: pointer;
            text-decoration: underline;
        }

        .fixDiv .showmorebtn:hover {
            color: #f00;
        }
        */
    .popList {
        width: 33vw;
        border: 1px solid #ddd;
        min-height: 60px;
        position: absolute;
        background-color: #fff;
        z-index: 3;
        padding: 0px 5px;
    }

        .popList ul {
            margin: 0px;
            padding: 0px;
        }

            .popList ul li {
                padding: 5px;
                border-bottom: 1px dashed #ddd;
                overflow: hiddem;
                list-style-type: none;
                margin-top: 3px;
                cursor: pointer;
                font-size: 12px;
            }

    .fixFilter {
        padding: 9px;
        width: 35px;
        height: 35px;
        background-color: #ff7f00;
        border: 1px dashed #f8fdf8;
        position: absolute;
        top: 0px;
        left: 0px;
        border-radius: 50px;
        z-index: 100;
        color: #fff;
        cursor: pointer;
        font-size: 15px;
    }

        .fixFilter:hover {
            color: #f00;
        }

    .filter_header {
        border: 1px solid #eee;
        padding: 0 15px;
        border-right: 0px;
        background-color: #fff;
        color: #464646;
        cursor: pointer;
        height: 40px;
        display: flex;
        align-items: center;
        justify-content: space-between;
    }

    .K_datecontrol {
        border: 1px solid #ddd;
        width: 240px;
    }

    .K_input {
        border: 0px;
        border-right: 1px solid #ddd;
        padding: 3px;
        background-color: #eee;
    }

        .K_input:focus {
            outline: none;
        }

    .K_datecontrol .K_icon {
        color: #ea3c05;
        font-size: 12px;
        cursor: pointer;
    }

    .K_icon:hover {
        color: #f00;
    }

    @media (min-width: 730px) {
        .daterangepicker.ltr .ranges {
            float: none !important;
            text-align: center;
        }
    }

    .filterHeader {
        background-color: #D04A02;
        padding: 0 15px;
        color: #fff;
        cursor: pointer;
        height: 40px;
        display: flex;
        align-items: center;
        justify-content: space-between;
    }

        .filterHeader p {
            font-size: 20px;
            margin-bottom: 0;
        }

    .filterNumber {
        background-color: #EB8C00;
        font-size: 16px;
    }

    .k_photo {
        width: 120px;
        height: 120px;
        background-color: #EB8C00;
        color: #fff;
        font-size: 20px !important;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /**/
    .boxed {
        background: #f0f0f0;
    }

    .Search_top {
        background-image: url("/gtsventure/bms/Admin/HomePage/DownloadFile?fileIds=194b102a-74ef-42fb-8985-4c4e082e2f3b");
        background-repeat: no-repeat;
        background-size: cover;
        background-position: center;
        display: flex;
        height: 120px;
        align-items: center;
        justify-content: center;
    }

    .Search_top_bg {
        background-color: #E0301E;
        padding: 20px;
    }

    .btn-lg,
    .btn-warning:focus {
        background: #fff;
        color: #E0301E;
        border: none;
    }

    .Search_main {
        width: 90vw;
        margin: 30px auto;
        display: flex;
    }

    .Search_main_left {
        width: 300px;
        margin-right: 15px;
    }

    .Search_main_right {
        width: calc(100% - 315px);
        background: #fff;
    }

    .ng-scope-m {
        background: #fff;
        height: 30px;
        margin-left: 15px;
        padding: 10px 15px;
        margin-bottom: 2px;
        display: flex;
        align-items: center;
        justify-content: space-between;
    }

    .badge {
        border-radius: 2px;
        margin-right: 10px;
    }

    .badge-count {
        background: #707070;
        color: #fff;
    }

    .ng-binding {
        font-size: 16px;
    }

    .spanText_h1 {
        font-size: 20px;
        color: #D04A02;
        font-family: Arial, sans-serif;
        font-weight: bold;
        padding: 3px;
    }

    .rtRow_news {
        display: flex;
        width: 100%;
        margin-top: 10px;
    }

        .rtRow_news p {
            margin-bottom: 0;
            width: calc(50% - 5px);
            display: flex;
        }

        .rtRow_news .spanTitle {
            width: 150px;
            display: block;
        }

        .rtRow_news .ng-binding {
            font-size: 12px;
            width: calc(100% - 150px);
        }

    .rtRow_m {
        width: calc(100% - 120px);
        margin-left: 10px;
    }

    .filterShow-top {
        display: flex;
        font-size: 20px;
        border-bottom: solid 1px #ccc;
        align-items: center;
    }

        .filterShow-top .glyphicon {
            padding: 0 10px;
        }

    .filterContent ul {
        margin: 0;
    }

    .filter-btn {
        display: none;
    }

    .spanText_h1 .glyphicon {
        left: 10px;
    }

    @media(max-width:1530px) {
        .navbar-top-links > li > a {
            padding: 0 15px;
        }

        .rtRow_news p {
            flex-flow: column;
        }

        .rtRow_news .spanTitle {
            width: 150px;
        }

        .rtRow_news .ng-binding {
            width: 100%;
        }

        .rtRow_news {
            margin-top: 0;
        }
    }

    @media(max-width:1000px) {
        .k_photo {
            width: 80px;
            height: 80px;
            font-size: 12px !important;
        }

        .rtRow_m {
            width: calc(100% - 10px);
            margin: 0;
            margin-left: 10px;
        }

        .ng-binding {
            font-size: 14px;
        }

        .Search_main {
            width: calc(100vw - 5px);
            margin: 5px auto;
        }

        .Search_top {
            height: 80px;
        }

        .imgSrc-img {
            width: 80px;
            height: 80px;
        }

        .searchInput {
            width: calc(80vw - 100px);
            height: 30px;
            border: none;
        }

        .btn-lg,
        .btn-warning:focus {
            height: 30px;
            padding: 0;
            font-size: 14px;
            min-width: 80px;
            margin-top: -1px;
            margin-right: 0;
        }

        .Search_main_left {
            position: fixed;
            z-index: 11;
            background: #fff;
            left: -300px;
        }

        .Search_main_right {
            width: 100%;
        }

        .dataItem {
            margin: 0 5px;
            padding: 5px 0;
        }

        .rtRow_news .spanTitle {
            width: 110px;
        }

        .rtRow_news {
            flex-flow: column;
            margin-top: 0;
            padding: 0 3px;
        }

            .rtRow_news p {
                width: 99% !important;
            }

            .rtRow_news .ng-binding {
                text-align: right;
                width: calc(100% - 110px);
            }

        .spanText_h1 {
            font-size: 16px;
        }

        .spanTitle {
            font-size: 11px;
        }

        .Search_top_bg {
            padding: 10px;
        }

        .filter-btn {
            display: block;
            position: absolute;
            left: 300px;
            min-width: auto;
            font-size: 21px;
            background-color: #D04A02;
            color: #fff;
            padding: .175rem .5rem;
            margin-bottom: 5px;
        }

            .filter-btn:focus,
            .filter-btn:hover {
                background-color: #D04A02;
                color: #fff;
            }

        .rtRow_news p {
            flex-flow: row;
        }

        .Search_top_bg div i {
            background: #fff;
            height: 30px;
            display: block;
            width: 50px;
            float: left;
            font-size: 24px;
            line-height: 30px;
            padding: 0 5px;
        }

        .filterItem {
            margin-bottom: 5px;
        }

        .moble-search {
            display: flex;
            overflow-x: auto;
            margin-top: 5px !important;
            justify-content: center;
        }

        .ng-binding {
            font-size: 12px;
            padding: 5px 10px;
        }
    }

    .Search_main_right_hide {
        width: calc(100%);
        background: #fff;
    }
</style>
<link href="/gtsventure/bms/Admin/HomePage/DownloadFile?fileIds=8df13e2a-ab01-4644-82a2-7d4bebc66850" rel="stylesheet" />
<div ng-app="myApp" ng-controller="appController" style="display:none;" id="appController">

    <div class="Search_top">

        <div class="Search_top_bg">
            <div>
                <i class="mdi mdi-magnify"></i>
                <input ng-model="searchkey" ng-keyup="enterEvent($event)" class="searchInput" />
                <button type="button" class="btn btn-warning btn-lg" ng-click="likeSearch('')">Search</button>
            </div>
            <div class="popList" ng-show="autoShow">
                <ul>
                    <li ng-repeat="o in AutoResultList" ng-click="likeSearch(o.Title)">{{o.Title}}</li>
                    <li style="border:0px;text-align:right;"><span class="removeA" ng-click="autoShow=false;">Close</span></li>
                </ul>
            </div>
        </div>
    </div>
    <div style="text-align:center;margin-top:30px;" class="moble-search">
        <span class="searchType" ng-repeat="o in businessTypes"
              ng-click="typeSelect(o)" ng-class="{'current':o.checked}">{{o.Value}}</span>
    </div>
    <div class="Search_main">
        <div class="Search_main_left">
            <button type="button" class="btn btn-pwc filter-btn"><i class="mdi mdi-filter"></i></button>
            <div>
                <div class="fixFilter" title="Show filters" ng-hide="!filterHide" ng-click="filterHide=false"><span class="glyphicon glyphicon-filter"></span></div>
            </div>
            <div class="filterHeader">
                <!-- <span class="glyphicon "></span>-->
                <p>All Results</p>
                <div>
                    <a href="#"><span class="badge" style="background-color:#fff;color:#FF5722; font-size: 16px;">{{SearchResultItem.Total}}</span></a>
                    <span class="pull-right glyphicon glyphicon-triangle-top" ng-hide="true"></span>
                </div>
            </div>
            <div style="border:1px solid #eee;border-top:0px;">
                <div ng-repeat="bo in filterData" ng-hide="bo.DisplayField=='ExpirationDate'||bo.DisplayField=='DocType'||bo.display==false">
                    <div ng-click="bo.show=!bo.show" class="filter_header">
                        <span>{{bo.DisplayName}}</span>
                        <div>
                            <a href="#"> <span class="badge filterNumber">{{bo.Count}}</span></a>
                            <span class="glyphicon  pull-right" ng-class="{'glyphicon-chevron-down':!bo.show,'glyphicon-chevron-up':bo.show}" style="margin-top:2px;"></span>
                        </div>
                    </div>
                    <div ng-show="bo.show">
                        <div ng-repeat="o in bo.Mapping" ng-click="select(o)" class="ng-scope-m" ng-hide="o.Value==''">
                            <span style="display:inline-block;padding-left:3px;font-size:14px;color:#888;">{{o.Value}}</span>
                            <span class="pull-right">
                                <a href="#"><span class="badge pull-right badge-count">{{o.Count}}</span></a>
                            </span>
                        </div>
                    </div>
                </div>
                <div ng-hide="true">
                    <div class="filter_header" ng-click="ExpireationShow=!ExpireationShow">
                        <span class="glyphicon glyphicon-stop" style="font-size:11px;color:#b9b8b8;"></span><span>&nbsp;&nbsp;Expiration Date </span><span class="glyphicon  pull-right" ng-class="{'glyphicon-chevron-down':!ExpireationShow,'glyphicon-chevron-up':ExpireationShow}"
                                                                                                                                                           style="margin-top:2px;"></span>
                    </div>
                    <div style="padding:5px;" ng-show="ExpireationShow">
                        <div class="K_datecontrol">
                            <input type="text" class="K_input" id="K_ExpiredDate" readonly>
                            <input type="hidden" id="ExpiredDate_start" />
                            <input type="hidden" id="ExpiredDate_end" />
                            <span class="glyphicon glyphicon-remove K_icon" id="K_Clear_Expireddate"></span>
                            <span class="glyphicon glyphicon-option-vertical"></span>
                            <span class="glyphicon glyphicon-calendar K_icon" id="K_clandar_Expireddate"></span>
                        </div>
                    </div>
                    <button id="datechange" ng-hide="true" ng-click="select('')"></button>
                </div>
            </div>
        </div>
        <div class="Search_main_right" ng-class="{'Search_main_right_hide':businessTypes[0].checked||false}">

            <div ng-show="SearchItems.length>0">
                <div class="filterShow-top">
                    <span class="glyphicon glyphicon-filter"></span> <span> Filter</span>
                    <!-- <span class="glyphicon  pull-right" ng-class="{'glyphicon-chevron-up':filterShow,'glyphicon-chevron-down':!filterShow}"></span>>-->
                    <div class="filterContent" ng-show="filterShow">
                        <div>
                            <ul>
                                <li ng-repeat="o in SearchItems" class="filterItem"><span>{{o.name}}:&nbsp;</span>{{o.item}}<span class="glyphicon glyphicon-remove removeitem" ng-click="removeFilter(o)"></span></li>
                            </ul>
                        </div>
                        <div class="SearchItems-clear" ng-show="SearchItems.length>1"><a class="removeA" ng-click="removeFilter('all')"><span class="glyphicon glyphicon-remove"></span> Clear all</a></div>
                    </div>
                </div>

            </div>

            <div style="border-top: solid 1px #ccc" ng-show="datalist.length==0&&busy!=1">
                <span class="glyphicon glyphicon-info-sign"></span><span>&nbsp;&nbsp;No document.</span>
            </div>

            <div class="row" ng-show="datalist.length>0" ng-repeat="o in datalist">
                <div style="height:100px;" class="hidden-sm hidden-xs hidden-md" ng-class="{'col-lg-2':filterHide}" ng-show="filterHide">
                </div>
                <div class="col-md-12 " ng-class="{'col-lg-8':filterHide}">
                    <div>

                        <div class="dataItem" ng-show="o.Type=='Document'">
                            <div ng-show="o.imgSrc=='none'"><img style="max-width:140px;max-height:140px;" src="/gtsventure/bms/Admin/HomePage/DownloadFile?fileIds=c6e435be-e686-429a-82d5-7dc88ef4026f" /></div>
                            <div ng-show="o.imgSrc!='none'"><img src="{{o.imgSrc}}" class="imgSrc-img" /></div>
                            <div class="rtRow_m" ng-class="">

                                <div class="rtTitle spanText_h1">
                                    <a class="titleA" href="{{o.url}}" target="_blank">{{o.Title}}</a>&nbsp;&nbsp;
                                    <a class="titleB" ng-show="o.SourceLink!=''&&false" href="{{o.SourceLink}}" target="_blank">Open source file</a>
                                </div>
                                <div class="rtRow rtRow_news">
                                    <p><span class="spanTitle">Document format:</span><span class="spanText">{{o.Format}}</span></p>
                                    <p><span class="spanTitle">Expired date:</span><span class="spanText">{{o.ExpirationDate}}</span></p>
                                </div>
                                <div class="rtRow rtRow_news">
                                    <p><span class="spanTitle">Document size:</span><span class="spanText">{{o.DocumentSize}}</span></p>
                                    <p><span class="spanTitle">Tag:</span><span class="tagSpan" ng-repeat="t in o.Tag"><i>{{t}} </i></span></p>
                                </div>

                                <div class="rtRow rtRow_news">
                                    <p><span class="spanTitle">Author:</span><span class="spanText">{{o.CreateBy}}</span></p>
                                    <p><span class="spanTitle">Create date:</span><span class="spanText">{{o.CreateDate}}</span></p>
                                </div>
                                <div class="rtRow rtRow_news">
                                    <p ng-show="o.ExpirationDays>=0">
                                        It will expire after&nbsp;&nbsp;&nbsp;{{o.ExpirationDays}} days</span>
                                    </p>
                                    <p ng-show="o.ExpirationDays<0">
                                        It has been expired&nbsp;&nbsp;&nbsp;{{o.ExpirationDays}} days</span>
                                    </p>
                                </div>

                            </div>
                        </div>


                    </div>

                    <div class="dataItem" ng-show="o.Type!='Document'">
                        <div ng-class="">
                            <div class="k_photo" ng-show="o.Type!='Document'">
                                {{o.Type}}
                            </div>
                        </div>
                        <div class="rtRow_m" ng-class="">
                            <div class="spanText spanText_h1">
                                <a class="titleA" href="{{o.url}}" target="_blank">{{o.Title}}</a>&nbsp;&nbsp;
                                <a class="titleB" ng-show="o.SourceLink!=''&&false" href="{{o.SourceLink}}" target="_blank">Open source file</a>
                            </div>
                            <div class="rtRow rtRow_news">
                                <p><span class="spanTitle">Content:</span><span class="spanText">{{o.Content}}</span></p>
                                <p><span class="spanTitle">Create Date:</span><span class="spanText">{{o.CreateDate}}</span></p>

                            </div>
                            <div class="rtRow rtRow_news">
                                <p><span class="spanTitle">Create By:</span><span class="spanText">{{o.CreateBy}}</span></p>
                                <p><span class="spanTitle">Type:</span><span class="spanText">{{o.Type}}</span></p>
                            </div>
                        </div>
                    </div>

                </div>
            </div>
            <div style="height:100px;" class="hidden-sm hidden-xs hidden-md" ng-class="{'col-lg-2':filterHide}" ng-show="filterHide">
            </div>

            <div style="padding:10px;border:1px solid #e2dede;background-color:#fff;color:#FF5722;margin:10px 0px; text-align:center;" ng-show="busy==1">
                Data is loading...
            </div>
            <div style="text-align:center;padding:30px;" ng-show="busy==0"><button type="button" class="btn btn-primary" ng-click="CallSearch('more')">Show more</button></div>
        </div>
    </div>
</div>

<!--commom.js-->
<script src="/gtsventure/bms/Admin/HomePage/DownloadFile?fileIds=632e800a-5940-41bf-bd33-5808677a9af9"></script>
<!--moment.js-->
<script src="/gtsventure/bms/Admin/HomePage/DownloadFile?fileIds=374cd0e3-b362-4694-910e-7d27b595ab8b"></script>
<!--datarangepeacker.js-->
<script src="/gtsventure/bms/Admin/HomePage/DownloadFile?fileIds=6867b54d-94e4-4459-a3c8-67855960aa8e"></script>
<!--bootstrap-datetimepicker.js-->
<script src="/gtsventure/bms/Admin/HomePage/DownloadFile?fileIds=d8e8c452-f397-462a-9177-5d17218fc589"></script>

<!--angular.js-->
<script src="/gtsventure/bms/Admin/HomePage/DownloadFile?fileIds=5a62e82d-2959-4f54-b57d-da1473e947ef"></script>

<!--linq.min.js-->
<script src="/gtsventure/bms/Admin/HomePage/DownloadFile?fileIds=5aab16d3-fc58-407b-afa4-1a8e697499e9"></script>
<!--ModularConfig.js-->
<script src="/gtsventure/bms/Admin/HomePage/DownloadFile?fileIds=4157bb97-db0a-41b6-a50a-11b788e60776"></script>


<script>
    var SearchCode = "PwCCNHK_GTSVenture_Docs_v2";
    var baseUrl = "/gtsventure/bms";

    function getBaseurl() {
        return baseUrl;
    };

    function getUrlParam(name) {
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
        var r = window.location.search.substr(1).match(reg);
        if (r != null) return decodeURI(r[2]);
        return '';
    };

    $('#K_ExpiredDate').daterangepicker({
        "startDate": moment().format("YYYY-MM-DD"),
        "endDate": moment().add("day", 7).format("YYYY-MM-DD"),
    }, function(start, end, label) {
        $("#ExpiredDate_start").val(start.format('YYYY-MM-DD'));
        $("#ExpiredDate_end").val(end.format('YYYY-MM-DD'));
        $("#datechange").click();
    });

    $("#K_clandar_Expireddate").click(function() {
        $('#K_ExpiredDate').focus();
    });

    $("#K_Clear_Expireddate").click(function() {
        $('#K_ExpiredDate,#ExpiredDate_start,#ExpiredDate_end').val("");
    });
    $("#K_Clear_Expireddate").click();

    function ClearDateTime() {
        $('#K_ExpiredDate,#ExpiredDate_start,#ExpiredDate_end').val("");
    }
</script>

<script>
    var currentUser = CustomCodeResultData.CurrentUser.UserInfo;
    var StaffCode = currentUser.StaffCode;
    var UserID = currentUser.UserID;

    var app = angular.module('myApp', []);
    app.controller('appController', function($scope, $http) {
        $scope.filterShow = true;
        $scope.Search = "abcd";














        $scope.findDatas = function(SourceIDS, list) {
            if (SourceIDS == "") return;
            var searchItem = [];
            searchItem.push({
                Method: "And",
                Operator: "In",
                Name: "_id",
                Value: SourceIDS
            });
            var requrl = getBaseurl() + "/CustomApi/RetrieveQueryDocs";
            var Jsondata = {};
            Jsondata.Token = "";
            Jsondata.EntityName = "q10z7uxi3ad";
            Jsondata.size = 1000000;
            Jsondata.index = 0;
            Jsondata.SearchItem = searchItem;
            Jsondata.Order = {
                "C4-ModifyDate": "Descending"
            };
            $http.post(requrl, Jsondata).success(function(response) {
                console.log("$scope.findDatas", response);
                angular.forEach(response.Data.rows, function(o) {
                    var df = o.DocumentFile == "" ? JSON.parse(o.DocumentMultipleFile) : JSON.parse(o.DocumentFile);
                    if (o.DocumentFile != "")
                        for (i = 0; i < list.length; i++) {
                            if (list[i]._id == o._id) {
                                list[i].imgSrc = df[0].imgSrc;
                                break;
                            }
                        }
                });
            });
        };


















        $scope.Enterkey = 0;
        $scope.enterEvent = function(e) {
            var keycode = window.event ? e.keyCode : e.which;
            if (keycode == 13) {
                $scope.Enterkey = 1;
                $scope.CallSearch();
                $scope.autoShow = false;
            }
            else {
                $scope.Enterkey = 0;
                $scope.CallLikeSearch();
            }
        };









        $scope.processList = function (list) {
            var _ids = "";
            angular.forEach(list, function (o) {

                var type = o.NoNotesExternalSourceURL.split("/vForm/")[1].split("/preview/")[0];
                type = type.replace("New", "");


                var SourceLink = o.SourceLink == null || o.SourceLink == '' ? '' : getBaseurl() + "/" + o.SourceLink;
                var url = o.NoNotesExternalSourceURL;
                console.log("SourceLink", SourceLink);
                if (type == "Comments") { type = "Comments"; url = SourceLink; }
                else if (type == "RichTextBox") { type = "Comments"; url = SourceLink; }
                else if (type == "ProjectManagement") type = "Project";
                else if (type == "Opportunities") type = "Opportunities";
                else if (type == "Product") type = "Product";
                else if (type == "Document") type = "Document";

                if (type == "Document") _ids = _ids == "" ? o.SourceID : _ids + "|C4|" + o.SourceID;
                var title = o.Title;
                var Content = o.Content.length > 50 ? o.Content.substr(0, 50) : o.Content;

                var k = {
                    "Title": title,
                    "Content": Content,
                    "CreateBy": o.C4_CreateBy,
                    "CreateDate": o.C4_CrateDate,
                    "_id": o.SourceID,
                    "url": url,
                    "Type": type,
                    "imgSrc": "none",
                    "SourceLink": SourceLink
                };

                if (type == "Document")
                    k = {
                        "Title": title,
                        "Content": Content,
                        "CreateBy": o.C4_CreateBy,
                        "CreateDate": o.C4_CrateDate,
                        "_id": o.SourceID,
                        "url": url,
                        "Type": type,
                        "imgSrc": "none",
                        "ExpirationDate": o.ExpirationDate,
                        "ExpirationDays": moment(o.ExpirationDate).diff(moment(), 'days'),
                        "Format": o.Format,
                        "Tag": o.Tag,
                        "DocumentSize": o.DocumentSize,
                        "DocumentOwner": o.DocumentOwner,
                        "SourceLink": SourceLink
                    };

                $scope.datalist.push(k);
            });
            $scope.findDatas(_ids, $scope.datalist);
        };




















        $scope.filterData = [];
        $scope.processFilters = function(StatisticResult) {
            var oldFilters = $scope.filterData;
            $scope.filterData = StatisticResult;
            angular.forEach($scope.filterData, function (o) {
               
                o.display = false;
                angular.forEach(o.Mapping, function (x) {
                    if (x.Value != '') o.display = true;
                });

                for (i = 0; i < oldFilters.length; i++) {
                    var k = oldFilters[i];
                    if (k.DisplayField == o.DisplayField) {
                        o.show = k.show;
                        angular.forEach(o.Mapping, function(x) {
                            for (j = 0; j < k.Mapping.length; j++) {
                                var g = k.Mapping[j];
                                if (x.Value == g.Value) {
                                    x.checked = g.checked;
                                    break;
                                }
                            }
                        });
                    }
                }
            });
        };

















        $scope.autoShow = false;
        $scope.CallLikeSearch = function () {
            if ($scope.searchkey == '') {
                $scope.AutoResultList = [];
                $scope.autoShow = false;
                return;
            }
            var Jsondata = {
                "t": "AutoComplete",
                "q": $scope.searchkey,
                "f": "",
                "s": "",
                "p": 1
            };
            var requrl = getBaseurl() + "/Admin/Home/ESSearchResultByType";
            $http.post(requrl, Jsondata).success(function (response) {
                var searchResult = JSON.parse(JSON.parse(response));
                console.log("searchResult", searchResult);

                var SearchResultItem = JSON.parse(searchResult.ass.SearchSettings[0].SearchResultItem);
                var AutoResultList = SearchResultItem.ResultList;
                $scope.AutoResultList = AutoResultList;
                angular.forEach($scope.AutoResultList, function (x) {
                    x.Title = $scope.processTitle($scope.searchkey, x.Title);
                });
                if (AutoResultList == undefined) $scope.autoShow = false;
                else {
                    $scope.autoShow = AutoResultList.length > 0 ? true : false;
                }
                console.log("AutoResultList", AutoResultList);
                if ($scope.Enterkey == 1) {
                    $scope.autoShow = false;
                }

            })
        };







        $scope.processTitle = function (key, t) {
            return t;
        };






        $scope.businessTypes = [];
        $scope.initBusinessTypes = function () {
            if ($scope.businessTypes.length > 0) return;
            var obj = {
                ESName: "DocType",
                Value: "All",
                DisplayName: "全部",
                Count: 0,
                checked: true
            };
            $scope.businessTypes.push(obj);
            var items = getModulesInfo().Data.rows[0].ModularDetail;
            for (i = 0; i < items.length; i++) {
                if (items[i] == "Opportunity") {
                    $scope.businessTypes.push({
                        ESName: "DocType",
                        Value: "Opportunity",
                        DisplayName: "商机",
                        Count: 0,
                        checked: false
                    });
                }
                else if (items[i] == "Product"){
                    $scope.businessTypes.push({
                        ESName: "DocType",
                        Value: "Product",
                        Count: 0,
                        DisplayName: "产品",
                        checked: false
                    });
                }

                 
                else if (items[i] == "Project") {
                    $scope.businessTypes.push({
                        ESName: "DocType",
                        Value: "Project",
                        DisplayName: "项目",
                        Count: 0,
                        checked: false
                    });
                } 
            }

            $scope.businessTypes.push({
                ESName: "DocType",
                Value: "Document",
                DisplayName: "文档",
                Count: 0,
                checked: false
            });


        };



        $scope.typeSelect = function (o) {
            if (o.checked) return;
            angular.forEach($scope.businessTypes, function (x) {
                x.checked = false;
                if (o.Value == x.Value) x.checked = true;
            });
            $scope.likeSearch('');
        };











        $scope.SearchFilter = "ExpirationDate__RDate01/05/2019-31/12/2023";
        $scope.searchkey = "";
        $scope.SearchResultItem = [];
        $scope.datalist = [];
        $scope.pageIndex = 1;
        $scope.busy = 0;

        $scope.CallSearch = function(Seachtype) {
            if ($scope.busy == 1) return;
            $scope.busy = 1;
            if (Seachtype == 'more') {
                $scope.pageIndex += 1;
            } else {
                $scope.autoShow = false;
                $scope.datalist = [];
                $scope.pageIndex = 1;
            }

            var searchFilter = $scope.SearchFilter;
            var businessSearch = "";
            if ($scope.businessTypes.length == 0)
            {
                searchFilter += searchFilter == "" ? businessSearch : "||" + businessSearch;
            }
            else{
                for (i = 0; i < $scope.businessTypes.length; i++) {
                    var k = $scope.businessTypes[i];

                    if (k.checked && k.Value == "All") {
                        businessSearch = "DocType";
                        angular.forEach($scope.businessTypes, function (x) {
                            if(x.Value!="All")
                            businessSearch =businessSearch+ "__" + x.Value;
                        });
                        console.log("businessSearch", businessSearch);
                        break;
                    }
                    


                    if (k.checked) {
                        businessSearch = "DocType__" + k.Value;
                        break;
                    }
                }
            }

            searchFilter += searchFilter == "" ? businessSearch : "||" + businessSearch;

            var Jsondata = {
                "t": "Documents",
                "q": $scope.searchkey,
                "f": searchFilter,
                "s": "",
                "p": $scope.pageIndex
            };
            var requrl = getBaseurl() + "/Admin/Home/ESSearchResultByType";
            $http.post(requrl, Jsondata).success(function(response) {
                var searchResult = JSON.parse(JSON.parse(response));
                console.log("searchResult", searchResult);

                var tempresult;
                for (i = 0; i < searchResult.ass.SearchSettings.length; i++) {
                    if (searchResult.ass.SearchSettings[i].SearchCode == SearchCode) {
                        tempresult = searchResult.ass.SearchSettings[i].SearchResultItem;
                        break;
                    }
                }
                var SearchResultItem = JSON.parse(tempresult);
                $scope.SearchResultItem = SearchResultItem;


                var StatisticResult = SearchResultItem.StatisticResult;
                
                $scope.processFilters(StatisticResult);
                console.log("StatisticResult", StatisticResult);


                console.log("SearchResultItem", SearchResultItem);
                var ResultList = SearchResultItem.ResultList;
                console.log("ResultList", ResultList);
                if (ResultList == undefined || ResultList.length < SearchResultItem.RecordPerPage) $scope.busy = 2;
                else $scope.busy = 0;
                $scope.processList(ResultList);
                console.log("$scope.datalist", $scope.datalist);
                $("#appController").show();
            })
        };
















        $scope.setTimeSearch = function() {
            $scope.SearchFilter = "";
            var ExpiredDate_start = $("#ExpiredDate_start").val();
            var ExpiredDate_end = $("#ExpiredDate_end").val();
            if (ExpiredDate_start != "" && ExpiredDate_end != "") {
                var tstring = "ExpirationDate__RDate{start}-{end}";
                $scope.SearchFilter = tstring.replace("{start}", moment(ExpiredDate_start).format("DD/MM/YYYY")).replace("{end}", moment(ExpiredDate_end).format("DD/MM/YYYY"));
            }
        };














        $scope.SearchItems = [];
        $scope.select = function(o) {

            $scope.SearchItems = [];
            if (o != '') o.checked = !o.checked;
            $scope.SearchFilter = "ExpirationDate__RDate01/05/2019-31/12/2023";
            $scope.setTimeSearch();
            angular.forEach($scope.filterData, function(k) {
                var exist = false;
                var searchItem = "";
                var displayItem = "";
                for (i = 0; i < k.Mapping.length; i++) {
                    var g = k.Mapping[i];
                    if (g.checked) {
                        exist = true;
                        searchItem = searchItem += "__" + g.Value;
                        displayItem = displayItem == "" ? g.Value : displayItem += " 、" + g.Value;
                    }
                }
                if (searchItem != "") {
                    searchItem = k.DisplayField + searchItem;
                    $scope.SearchFilter += $scope.SearchFilter == "" ? searchItem : "||" + searchItem;
                    $scope.SearchItems.push({
                        name: k.DisplayName,
                        item: displayItem
                    });
                }
            });
            console.log("SearchKey", $scope.SearchFilter);
            $scope.CallSearch('init');
        };










        $scope.likeClick = function() {
            if ($scope.searchkey != '' && $scope.AutoResultList.length > 0) $scope.autoShow = true;
        };










        $scope.likeSearch = function(title) {
            ClearDateTime();
            if (title != '') {
                $scope.AutoResultList = [];
                $scope.AutoResultList.push({
                    Title: title
                });
                $scope.searchkey = title;
            }
            $scope.autoShow = false;
            $scope.SearchFilter = "";
            $scope.filterData = [];
            $scope.SearchItems = [];
            $scope.CallSearch('init');
        };

        $scope.initBusinessTypes();
        var key = getUrlParam("key");
        $scope.likeSearch(key);












        $scope.removeFilter = function(o) {
            angular.forEach($scope.filterData, function(k) {
                if (o == 'all' || k.DisplayName == o.name) {
                    for (i = 0; i < k.Mapping.length; i++) {
                        k.Mapping[i].checked = false;
                    }
                }
            });
            $scope.select('');
        };


















    });
</script>

<script>
    $(document).ready(function() {
        $(".filter-btn").click(function() {
            {
                if (this.filterShow) {
                    this.filterShow = false;
                    $(".Search_main_left").css("left", "-300px");
                } else {
                    this.filterShow = true;
                    $(".Search_main_left").css("left", "0");
                }
            }
        });
      setTimeout(function(){
      $(document).attr("title","BMS-Search");},500);
    });
</script>